#ifndef __input_h__
#define __input_h__

#include "types.h"

#define _P1(nn)	(nn << 0)		//10 bits
#define _P2(nn)	(nn << 10)		//10 bits
#define _MISC(nn)	(nn << 20)		//12 bits

//player 1 input keys
#define I_UP		_P1(0x001)
#define I_DOWN		_P1(0x002)
#define I_LEFT		_P1(0x004)
#define I_RIGHT	_P1(0x008)
#define I_B1		_P1(0x010)
#define I_B2		_P1(0x020)
#define I_B3		_P1(0x040)
#define I_B4		_P1(0x080)
#define I_B5		_P1(0x100)
#define I_B6		_P1(0x200)
#define I_UP2		I_B3
#define I_DOWN2	I_B4
#define I_LEFT2	I_B5
#define I_RIGHT2	I_B6

//player 2 input keys
#define I2_UP		_P2(0x001)
#define I2_DOWN	_P2(0x002)
#define I2_LEFT	_P2(0x004)
#define I2_RIGHT	_P2(0x008)
#define I2_B1		_P2(0x010)
#define I2_B2		_P2(0x020)
#define I2_B3		_P2(0x040)
#define I2_B4		_P2(0x080)
#define I2_B5		_P2(0x100)
#define I2_B6		_P2(0x200)
#define I2_UP2		I2_B3
#define I2_DOWN2	I2_B4
#define I2_LEFT2	I2_B5
#define I2_RIGHT2	I2_B6

//other keys
#define I_COIN1	_MISC(0x001)
#define I_COIN2	_MISC(0x002)
#define I_COIN3	_MISC(0x004)

#define I_TILT		_MISC(0x008)

#define I_START1	_MISC(0x010)
#define I_START2	_MISC(0x020)
#define I_START3	_MISC(0x040)
#define I_START4	_MISC(0x080)

#define I_SERVICE	_MISC(0x100)
#define I_ADVANCE	_MISC(0x200)
#define I_AUTOUP	_MISC(0x400)
#define I_HRESET	_MISC(0x800)

typedef struct dipinfo_s
	{
	char *Name;					//name of switch setting
	u32 Data;					//bits set
	} dipinfo_t;

typedef struct dip_s
	{
	char *Name;					//name of switch
	int Size;					//size (in bits)
	u32 Default;				//default value of this switch
	dipinfo_t Info[16];			//information about settings
	} dip_t;

class CInput
	{
	public:
		u32 input;				//input data
		u32 dip;					//dip switch data
	public:
		CInput();
		u32 Get();
		int GetKey(int n);							//returns key mapped for n
		void SetKey(int n,int scancode);		//maps key for n
		virtual void Poll(){}
		virtual int Init(){return(0);}
		virtual void Kill(){}
		virtual void SetDip(u32 d){dip = d;}
		virtual u32 GetDip(){return(dip);}
	};

#endif
